<template>
  <teleport to="body">
    <button @click="open">打开</button>
    <button @click="close">关闭</button>
  </teleport>
</template>
<script>
import { reactive, toRefs } from '@vue/composition-api'
export default {
    setup () {
      const state = reactive({
        modalOpen: false
      })
      const open = () => {
        state.modalOpen = true
      }
      const close = () => {
        state.modalOpen = false
      }
      return {
        ...toRefs(state),
        close,
        open
      }
    }
}
</script>
